<?php
class login
{ 
function authenticate($uname,$pword)
{
       
        include_once('db.php');	
	$str="SELECT * FROM `user` WHERE `uname`='$uname' and `pword`='$pword'";
	$result=mysql_query($str);
	$num=mysql_num_rows($result);
	if($num>0)
	{
		$row=mysql_fetch_array($result);
		if($row['role']==0)
		{
			$_SESSION['id']=$row['uid'];	
			$_SESSION['fname']=$row['fname'];
			$_SESSION['lname']=$row['lname'];
		    header("location:index.php");
		}
		else 
		{   
			
			$_SESSION['id']=$row['uid'];	
			$_SESSION['fname']=$row['fname'];
			$_SESSION['lname']=$row['lname'];
			header("location:article.php");
			
		}
		
	}
	else 
	{
	      $error='Authentication failed';	
		  return $error;
	}
}
}
?>

